<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 消息模板数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\MessageService;
use think\Request;

class MessageTemplateController extends VerifyController
{
    /**
     * @var \common\service\MessageService
     */
    protected $messageService;



    public function __construct()
    {
        parent::__construct();
        $this->messageService = new MessageService();
    }


    /**
     * 渲染消息模板
     * @param Request $request
     * @return \think\Response
     */
    public function render(Request $request)
    {
        try {
            $param = $request->param();
            $resData = $this->messageService->renderMsgTemplate($param['template_id'], $param['param']);
            return json(success_response('', $resData));
        } catch (LogicException $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }
}